from django.db import models


# Create your models here.

class CourseCate(models.Model):

	class Meta:
		db_table = "course_cate"
		verbose_name_plural = '课程分类'
		managed = False
		ordering = ['id']

	# id = models.ForeignKey(course,to_field=course.course_cate_id)
	id = models.BigIntegerField(primary_key=True)
	# course_cate_id = models.CharField(null=True,max_length=40,default="liangjun-test")
	name = models.CharField(null=True,max_length=40)
	description = models.CharField(null=True,max_length=1000)
	sort_no = models.CharField("序列号",null=True,max_length=10)

	def __str__(self):
		return self.name


class Course(models.Model):
	class Meta:
		db_table = "course"
		verbose_name_plural = '所有课程'
		managed = False

	id = models.BigIntegerField(primary_key=True)
	course_cate = models.ForeignKey(CourseCate)
	# course_cate_id = models.PositiveIntegerField()
	# course_cate_id = models.ForeignKey(CourseCate,to_field=CourseCate.id)
	# cate_name = models.ForeignKey(course_cate, to_field=course_cate.name)
	# course_cate_id = models.OneToOneField()
	word_bank_id = models.PositiveIntegerField()
	name = models.CharField(max_length=40)
	summary = models.TextField(max_length=1000)
	description = models.TextField(max_length=1000)
	description_time = models.CharField(max_length=100)
	image_name = models.CharField(max_length=40)
	video_name = models.CharField(max_length=40)
	is_quick_mode = models.PositiveSmallIntegerField()
	apple_iap_id = models.CharField(max_length=50)
	unit_price = models.DecimalField(max_digits=6, decimal_places=2)
	word_num = models.PositiveIntegerField()

	# def __init__(self):
	# 	super(course, self).__init__()
	# 	self.arg = arg
	#     return self.course_cate_id

	def __str__(self):
		return self.name
